package com.peaksport.pkms.learntest.service;

import org.apache.servicecomb.pack.omega.transaction.annotations.Participate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.peaksport.framework.base.dao.IBaseDAO;
import com.peaksport.framework.base.service.BillBaseService;
import com.peaksport.framework.exception.PKBizException;

@Service
public class TestPackTccService extends BillBaseService {

	
	@Override
	public IBaseDAO<?> getDAO() {
		return null;
	}

	@Participate(confirmMethod="auditBillForTcc_confirm",cancelMethod="auditBillForTcc_cancel")
	@Transactional
	public void auditBillForTcc(String pk,boolean isException, boolean isExceptionInConfirm, boolean isExceptionInCancel) {
		String checkSql = "select FBaseStatus from t_tst_billhead where FID='" + pk + "'";
		boolean b = isExistsForNative(checkSql);
		if (!b) throw PKBizException.throwException("不存在记录[%s]", pk);
		String updSql= "update t_tst_billhead set FBaseStatus=99 where FID='" + pk + "'";
		executeSqlForNative(updSql.toString());
		System.out.println("auditBillForTcc");
		if (isException) throw PKBizException.throwException("审核主表.try发生异常");
	}
	
	@Transactional
	public void auditBillForTcc_confirm(String pk,boolean isException, boolean isExceptionInConfirm, boolean isExceptionInCancel) {
		String updSql= "update t_tst_billhead set FBaseStatus=4 where FID='" + pk + "' and FBaseStatus=99";
		executeSqlForNative(updSql.toString());
		System.out.println("auditBillForTcc_confirm");
		if (isExceptionInConfirm) throw PKBizException.throwException("审核主表.confirm发生异常");
		
	}
	@Transactional
	public void auditBillForTcc_cancel(String pk,boolean isException, boolean isExceptionInConfirm, boolean isExceptionInCancel) {
		String updSql= "update t_tst_billhead set FBaseStatus=0 where FID='" + pk + "'and FBaseStatus=99";
		executeSqlForNative(updSql.toString());
		System.out.println("auditBillForTcc_cancel");
		if (isExceptionInCancel) throw PKBizException.throwException("审核主表.cancel发生异常");
	}
	
	
}
